Feature: Scenario Outline examples could be tagged '''''''''''''''''''''''''''''''''''''''''''''''''' Rule: Background: - Given File "steps.feature" with content: .. code:: gherkin Feature: Steps are executed by corresponding step keyword decorator Scenario Outline: Given I produce test @passed Examples: |outcome| |passed | @failed Examples: |outcome| |failed | @both Examples: |outcome| |passed | |failed | - Given File "pytest.ini" with content: .. code:: ini [pytest] markers = passed failed both - And File "conftest.py" with content: .. code:: python from pytest_bdd.compatibility.pytest import fail from pytest_bdd import given @given('I produce passed test') def passing_step(): ... @given('I produce failed test') def failing_step(): fail('Enforce fail') Scenario: - When run pytest ======== == ====== cli_args -m passed ======== == ====== ======== == ====== - Then pytest outcome must contain tests with statuses: ====== ====== passed failed ====== ====== 1 0 ====== ====== Scenario: Run pytest with no marker filter - When run pytest ======== == ====== cli_args -m failed ======== == ====== ======== == ====== - Then pytest outcome must contain tests with statuses: ====== ====== passed failed ====== ====== 0 1 ====== ====== Scenario: Run pytest with marker 'passed or failed' - When run pytest ======== == ================ cli_args -m passed or failed ======== == ================ ======== == ================ - Then pytest outcome must contain tests with statuses: ====== ====== passed failed ====== ====== 1 1 ====== ====== Scenario: Run pytest with marker 'not both' - When run pytest ======== == ======== cli_args -m not both ======== == ======== ======== == ======== - Then pytest outcome must contain tests with statuses: ====== ====== passed failed ====== ====== 1 1 ====== ====== Scenario: Run pytest with marker 'both' - When run pytest ======== == ==== cli_args -m both ======== == ==== ======== == ==== - Then pytest outcome must contain tests with statuses: ====== ====== passed failed ====== ====== 1 1 ====== ====== Scenario: Run pytest with all markers - When run pytest - Then pytest outcome must contain tests with statuses: ====== ====== passed failed ====== ====== 2 2 ====== ====== .. _rule-mixing-tags-on-feature--examples-level: Rule: Mixing tags on feature & examples level .. raw:: html .. _background-1: Background: - Given File "steps.feature" with content: .. code:: gherkin @feature_tag Feature: Steps are executed by corresponding step keyword decorator Scenario Outline: Given I produce test Examples: |outcome| |passed | @examples_tag Examples: |outcome| |failed | - Given File "pytest.ini" with content: .. code:: ini [pytest] markers = feature_tag examples_tag - And File "conftest.py" with content: .. code:: python from pytest_bdd.compatibility.pytest import fail from pytest_bdd import given @given('I produce passed test') def passing_step(): ... @given('I produce failed test') def failing_step(): fail('Enforce fail') Example: Run pytest with feature_tag - When run pytest ======== == =========== cli_args -m feature_tag ======== == =========== ======== == =========== - Then pytest outcome must contain tests with statuses: ====== ====== passed failed ====== ====== 1 1 ====== ====== Example: Run pytest with examples_tag - When run pytest ======== == ============ cli_args -m examples_tag ======== == ============ ======== == ============ - Then pytest outcome must contain tests with statuses: ====== ====== passed failed ====== ====== 0 1 ====== ====== Example: Run pytest with not feature_tag - When run pytest ======== == =============== cli_args -m not feature_tag ======== == =============== ======== == =============== - Then pytest outcome must contain tests with statuses: ====== ====== passed failed ====== ====== 0 0 ====== ====== Example: Run pytest with not examples_tag - When run pytest ======== == ================ cli_args -m not examples_tag ======== == ================ ======== == ================ - Then pytest outcome must contain tests with statuses: ====== ====== passed failed ====== ====== 1 0 ====== ====== Example: Run pytest with feature_tag and collect only - When run pytest ======== == =========== ============== cli_args -m feature_tag --collect-only ======== == =========== ============== ======== == =========== ============== - Then pytest outcome must match lines: +-------------------+ | collected 2 items | +===================+ +-------------------+ Example: Run pytest with examples_tag and collect only - When run pytest ======== == ============ ============== cli_args -m examples_tag --collect-only ======== == ============ ============== ======== == ============ ============== - Then pytest outcome must match lines: +-----------------------------------------------+ | collected 2 items / 1 deselected / 1 selected | +===============================================+ +-----------------------------------------------+ Example: Run pytest with not feature_tag and collect only - When run pytest ======== == =============== ============== cli_args -m not feature_tag --collect-only ======== == =============== ============== ======== == =============== ============== - Then pytest outcome must match lines: +------------------------------------+ | collected 2 items / 2 deselected\* | +====================================+ +------------------------------------+ Example: Run pytest with not examples_tag and collect only - When run pytest ======== == ================ ============== cli_args -m not examples_tag --collect-only ======== == ================ ============== ======== == ================ ============== - Then pytest outcome must match lines: +-----------------------------------------------+ | collected 2 items / 1 deselected / 1 selected | +===============================================+ +-----------------------------------------------+